import { http } from "@/utils/http";

export type commonResult<T> = {
  code: number;
  msg: string;
  result: T;
};

export type infoType = {

	id?: number,
	strategyName?: string,
	status?: number,
	deviceCount?: number,
	receiveCount?: number,
	CreatedAt?: string,
}
export type infoTypeList = {
  data: infoType[];
  total: number;
};

const List = '/business/alarm/v2/strategies';
const Url = '/business/alarm/v2/strategy';
export const getList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", List, {
    params
  });
};
export const getInfo = (params?: object) => {
  return http.request<commonResult<infoType>>("get", Url, {
    params
  });
};
export const addInfo = (data?: object) => {
  return http.request<commonResult<any>>("post", Url, {
    data
  });
};
export const editInfo = (data?: object) => {
  return http.request<commonResult<any>>("put", Url, {
    data
  });
};
export const deleteInfo = (data?: object) => {
  return http.request<commonResult<any>>("delete", Url, {
    data
  });
};
//获取设备弹窗列表
export const strategylist = (params?: object) => {
  return http.request<commonResult<infoType>>("get", "/business/alarm/v2/strategy/devices", {
    params
  });
};
//添加设备
export const addstrategy = (data?: object) => {
  return http.request<commonResult<any>>("post", "/business/alarm/v2/strategy/device", {
    data
  });
};
//取消设备
export const delstrategy = (data?: object) => {
  return http.request<commonResult<any>>("delete", "/business/alarm/v2/strategy/device", {
    data
  });
}
//获取接收人列表
export const receiverslist = (params?: object) => {
  return http.request<commonResult<infoType>>("get", "/business/alarm/v2/strategy/receivers", {
    params
  });
};
//添加接收人
export const addreceiver = (data?: object) => {
  return http.request<commonResult<any>>("post", "/business/alarm/v2/strategy/receive", {
    data
  });
};
//取消接收人
export const delreceiver = (data?: object) => {
  return http.request<commonResult<any>>("delete", "/business/alarm/v2/strategy/receive", {
    data
  });
}